#include <bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define in read()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

const int N = 110;
const int K = 29;

int a[N], n;
ll tot;

namespace bit {
	int tr[50];
	bool ins(int x) {
		per(i, K, 0) if(x >> i & 1) {
			if(tr[i]) x ^= tr[i];
			else return tr[i] = x, 1;
		} return 0;
	}
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in; rep(i, 1, n) a[i] = in, tot += a[i];
	sort(a + 1, a + n + 1, greater < int >());
	rep(i, 1, n) if(bit :: ins(a[i])) tot -= a[i];
	printf("%lld\n", tot);
	return 0;
}
